package pile.customer.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import pile.customer.entity.ResponseResult;
import pile.customer.service.IFrequentlyAskedQuestionsService;
import org.springframework.beans.factory.annotation.Autowired;
import pile.customer.entity.FrequentlyAskedQuestions;

import pile.customer.params.frequentlyAskedQuestions.DeleDTO;
import pile.customer.params.frequentlyAskedQuestions.ListDTO;

/**
 * <p>
 * 常见问题 前端控制器
 * </p>
 *
 * @author 郭天义
 * @since 2024-06-05
 */
@RestController
@RequestMapping("/frequentlyAskedQuestions")
public class FrequentlyAskedQuestionsController {

   @Autowired
   private IFrequentlyAskedQuestionsService frequentlyAskedQuestionsService;


   /**
   * 常见问题 新增
   * @param frequentlyAskedQuestions
   * @return
   */
   @PostMapping("/add")
   public ResponseResult add(@Validated @RequestBody FrequentlyAskedQuestions frequentlyAskedQuestions){
        return frequentlyAskedQuestionsService.add(frequentlyAskedQuestions);
   }

   /**
   * 常见问题 删除
   * @param deleDTO
   * @return
   */
   @PostMapping("/dele")
   public ResponseResult dele(@Validated @RequestBody DeleDTO deleDTO){
        return frequentlyAskedQuestionsService.dele(deleDTO);
   }

    /**
    * 常见问题 信息
    * @param frequentlyAskedQuestionsId
    * @return
    */
    @GetMapping("/info")
    public ResponseResult info(@RequestParam Integer frequentlyAskedQuestionsId){
        return  frequentlyAskedQuestionsService.info( frequentlyAskedQuestionsId);
    }

    /**
    * 编辑 常见问题
    * @param frequentlyAskedQuestions
    * @return
    */
    @PostMapping("/edit")
    public ResponseResult edit(@Validated @RequestBody  FrequentlyAskedQuestions frequentlyAskedQuestions){
        return  frequentlyAskedQuestionsService.edit(frequentlyAskedQuestions);
    }

    /**
    * 常见问题 列表
    * @param listDTO
    * @return
    */
    @PostMapping("/list")
    public ResponseResult listPage(@Validated @RequestBody ListDTO listDTO){
    return  frequentlyAskedQuestionsService.listPage(listDTO);
    }

    /**
     * 点击有无帮助
     * @param listDTO
     * @return
     */
    @PostMapping("/clickForHelp")
    public ResponseResult clickForHelp(@Validated @RequestBody ListDTO listDTO){
        return  frequentlyAskedQuestionsService.clickForHelp(listDTO);
    }


    /**
     * 常见问题 用户端调用 需要放行 没token 列表
     * @param listDTO
     * @return
     */
    @PostMapping("/userList")
    public ResponseResult userList(@Validated @RequestBody ListDTO listDTO){
        return  frequentlyAskedQuestionsService.userList(listDTO);
    }
}
